﻿package net.wangit.view.unit.grid;

import net.wangit.Row;
import net.wangit.context.ActionContext;
import net.wangit.view.unit.UnitComponent;
import net.wangit.view.util.Html;

public class VerticalGroup extends FormGrid {

	public VerticalGroup(ActionContext ac, UnitComponent unit) {
		super(ac, unit);
	}

	protected void writeRow(ActionContext ac, StringBuffer html, Row row,
			int rowIndex, String rowCss) {
		beginTable(html);
		top.write(ac, html, row, rowIndex, rowCss);
		for (int i = 0; i < groups.size(); i++) {
			Group group = (Group) groups.get(i);
			html.append("<tr");
			setAttribute(html, group.getGroupId());
			html.append("><td");
			Html.setAttribute(html, group.getGroupAttribute());
			html.append(" colspan=\"").append(uc.getColumn()).append("\">")
					.append(group.getGroupName()).append("</td></tr>");
			group.write(ac, html, row, rowIndex, rowCss);
		}

		html.append("</table>");
	}

	protected void setAttribute(StringBuffer html, String groupId) {
		html.append(" class=\"").append("GV").append("\"");
	}
}
